package IO流.字节;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;

public class 文件拷贝的升级 {
    public static void main(String[] args) throws IOException {
        //1.创建一个文件的对象
        FileInputStream fis=new FileInputStream("F\\aaa\\a.txt");

        //2.读取数据
        byte[] bytes = new byte[2];
        //根据字节数组进行读取
        int len = fis.read(bytes);
        System.out.println(len);//2
        System.out.println(new String(bytes,0,len));//ab

        int len1 = fis.read(bytes);
        System.out.println(len1);//2
        System.out.println(new String(bytes,0,len1));//cd

        int len2 = fis.read(bytes);
        System.out.println(len2);//1
        System.out.println(new String(bytes,0,len2));//e


        //3.释放资源
        fis.close();

    }
}
